package day03;

import com.sun.xml.internal.bind.v2.runtime.output.SAXOutput;

import java.util.Scanner;

public class OperDemo {
//    运算符的演示
    public static void main(String[] args) {
//        a++先赋值再自增，++a先自增再赋值
        int a = 1,b,c,d;
        b= a++;
        c= ++a;
        System.out.println("b="+b+",c="+c);

        int a1 =5 ,b1 =10,c1 = 5;
        boolean b2 = a>b;
        System.out.println(b2);
        System.out.println(c1<b1);
        System.out.println(a1==c1);
        System.out.println(c1++>5);//false,运算后c==6
        System.out.println(c1++>5);//true 运算之前c==6

        b2 =b1>=a && b<c;
        System.out.println(b2);
        System.out.println(b1<=c1 && b1>a1);//false
        System.out.println(a1==b1&&c1>b1);//false
        System.out.println(b1!=c1 && a1<b1);//true

        System.out.println("--------------------");

        System.out.println(b1>a1 || b1<c1);
        System.out.println(b1<c1 || b1>a1);
        System.out.println(a1==b1 || c1>b1);


        System.out.println("c1------->"+c1);
        boolean b3 = a1>b1 && c1++>2;//发生短路了 不在进行后面的运算
        System.out.println(b3);
        System.out.println(c1);

        boolean b4 = a1<b1 || c1++>2;//发生短路了 不在进行后面的运算
        System.out.println(b4);
        System.out.println(c1);

//        注意
        short s  = 10;
//        s = s+10;这里会编译错误，默认为整形计算
        s +=10;//这里不会出错，自带强转 s = (short)(s+10);


//        System.out.println("请输入您的姓名");
//        Scanner sc = new Scanner(System.in);
//        String userName = sc.next();
//        System.out.println("请输入您的年龄");
//        int age = sc.nextInt();
//        System.out.println("您的姓名是:"+userName+"\n年龄："+age);

        System.out.println("-->"+10+20L);//遇到字符串就自动类型转换了
        System.out.println(10+20L+"-->");
        System.out.println(10+"-->"+20L);

//        三目运算符
        int para1 =3,para =6;
        int max = para>para1?para:para1;
        System.out.println(max);

//        顺序结构：亘古不变
//        分支结构：if，else
//        循环结构：for（），while，do while

    }

}
